﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUSINESS_OBJECT;

namespace CRM.customer
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        SCHEDULEe sch = new SCHEDULEe();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) 
            {
                //DataTable dt = sch.GetRecords(-99, "", "", Convert.ToDateTime("1-1-1800"), false, " and ");
                DataTable dt = sch.GetRecords(-99, "", "", Convert.ToDateTime("1/1/1800"), false, " and ");
                GridView1.DataSource=dt;
                GridView1.DataBind();
            }


        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            sch.SC_ID = -99;
            sch.SC_TYPE = txttype.Text;
            sch.SC_DESCRIPTION = Txtdesc.Text;
            sch.DATE = Convert.ToDateTime(Txtdate.Text);
            sch.ISDELETED = false;
            sch.SaveRecords();
            Response.Redirect("schedule.aspx");


        }

        protected void btnEdit_Command(object sender, CommandEventArgs e)
        {
           // DataTable dt = sch.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), "", "", Convert.ToDateTime("1/1/1800"), false, " and ");
            DataTable dt = sch.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), "", "", Convert.ToDateTime("1/1/1800"), false, " and ");
                Txtid.Text=dt.Rows[0]["SC_ID"].ToString();
                txttype.Text=dt.Rows[0]["SC_TYPE"].ToString();
                Txtdesc.Text=dt.Rows[0]["SC_DESCRIPTION"].ToString();
                Txtdate.Text = dt.Rows[0]["DATE"].ToString();
              
        }

        protected void btDelete_Command(object sender, CommandEventArgs e)
        {
            DataTable dt = sch.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()), "", "", Convert.ToDateTime("1/1/1800"), false, " and ");


            sch.SC_ID =Convert.ToInt64(dt.Rows[0]["SC_ID"].ToString());
            sch.SC_TYPE = dt.Rows[0]["SC_TYPE"].ToString();
            sch.SC_DESCRIPTION = dt.Rows[0]["SC_DESCRIPTION"].ToString();
            sch.DATE =Convert.ToDateTime(dt.Rows[0]["DATE"].ToString());
            sch.ISDELETED = true;
            sch.SaveRecords();
            Response.Redirect("schedule.aspx");
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }

        protected void updateok_Click(object sender, EventArgs e)
        {
            sch.SC_ID =Convert.ToInt64(Txtid.Text);
            sch.SC_TYPE = txttype.Text;
            sch.SC_DESCRIPTION = Txtdesc.Text;
            sch.DATE = Convert.ToDateTime(Txtdate.Text);
            sch.ISDELETED = false;
            sch.SaveRecords();
            Response.Redirect("schedule.aspx");

            

        }

        
    }
}
